package com.seeyon.apps.ext.ObxMsgPush.service;

import java.time.LocalDateTime;

import com.seeyon.apps.ext.ObxMsgPush.utils.MyUtils;
import com.seeyon.ctp.util.annotation.Inject;

public class ResService {
	@Inject
    private ResTokenStorage resTokenStorage;

    public String getToken() {
        String token = resTokenStorage.getToken();
        if (token == null) {
            // 当token过期或不存在时重新获取token
            token = MyUtils.getAccessToken("resGroupSecret");
            // 假设token的过期时间为3分钟
            LocalDateTime expirationTime = LocalDateTime.now().plusMinutes(3);
            // 将token和过期时间保存到TokenStorage中
            resTokenStorage.setToken(token, expirationTime);
        }
        return token;
    }
}
